package com.dengqi.mymodule.activity.network.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.dengqi.mymodule.R;
import com.dengqi.mymodule.activity.network.bean.MemberBean;
import com.dengqi.mymodule.activity.network.module.MemberContract;
import com.dengqi.mymodule.activity.network.module.MemberPresenter;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import androidx.recyclerview.widget.RecyclerView;

/**
 * @Author: dengqi
 * @CreateDate: 2020/10/19 17:25
 * @Description: 填写基本信息页面-1
 */
public class BaseInfoActivity extends RxAppCompatActivity implements View.OnClickListener, MemberContract.MemberInfoByPhoneView{

    private EditText et_phone, et_name;
    private Button btn_type, btn_add;
    private RecyclerView recyclerView;

    private MemberPresenter memberPresenter;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_customer);

        memberPresenter = new MemberPresenter(this);

        et_phone = findViewById(R.id.et_phone);
        et_name = findViewById(R.id.et_name);
        btn_type = findViewById(R.id.btn_type);
        btn_add = findViewById(R.id.btn_add);
        recyclerView = findViewById(R.id.recyclerView);

        btn_type.setOnClickListener(this);
        btn_add.setOnClickListener(this);

        et_phone.setText("13912938372");
        et_name.setText("蓝宝石");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_type:
                memberPresenter.getMemberInfoByPhone(this);
                break;
            case R.id.btn_add:
                startActivity(new Intent(this, SingleListActivity.class));
                break;
        }
    }

    @Override
    public String getShopId() {
        return "1";
    }

    @Override
    public String getBusId() {
        return "1";
    }

    @Override
    public String getPhone() {
        return et_phone.getText().toString();
    }

    @Override
    public void onMemberInfoByPhone(MemberBean.ListBean result) {
        et_name.setText(result.getName());
    }
}
